//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package cn.fan.model.vo;

//import io.swagger.annotations.ApiModel;
//import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
import org.springframework.data.mongodb.core.aggregation.LimitOperation;
import org.springframework.data.mongodb.core.aggregation.SkipOperation;
import org.springframework.data.mongodb.core.query.Criteria;

//@ApiModel("公共查询参数类")
public class BaseVo<T> implements Serializable {
//    @ApiModelProperty("主键ID")
    private String id;
//    @ApiModelProperty("分页索引")
    private Integer page = 1;
//    @ApiModelProperty("分页大小，默认30")
    private Integer size = 30;
    private int skip;
    private Sort sort;

    public static Criteria initCriteria() {
        return Criteria.where("delFlag").is(0);
    }

    public static Criteria initCriteria(String id) {
        Criteria criteria = initCriteria();
        if (StringUtils.isNotBlank(id)) {
            criteria.and("_id").is(id);
        }

        return criteria;
    }

    public Criteria getCriteria() {
        Criteria criteria = initCriteria();
        if (StringUtils.isNotBlank(this.id)) {
            criteria.and("_id").is(this.id);
        }

        return criteria;
    }

    public int getPageSkip() {
        this.skip = (this.page - 1) * this.size;
        return this.skip;
    }

    public List<AggregationOperation> getPageAgo() {
        List<AggregationOperation> agoList = new ArrayList();
        agoList.add(new SkipOperation((long)this.getPageSkip()));
        agoList.add(new LimitOperation((long)this.size));
        return agoList;
    }

    public BaseVo() {
    }

    public String getId() {
        return this.id;
    }

    public Integer getPage() {
        return this.page;
    }

    public Integer getSize() {
        return this.size;
    }

    public int getSkip() {
        return this.skip;
    }

    public Sort getSort() {
        return this.sort;
    }

    public BaseVo<T> setId(String id) {
        this.id = id;
        return this;
    }

    public BaseVo<T> setPage(Integer page) {
        this.page = page;
        return this;
    }

    public BaseVo<T> setSize(Integer size) {
        this.size = size;
        return this;
    }

    public BaseVo<T> setSkip(int skip) {
        this.skip = skip;
        return this;
    }

    public BaseVo<T> setSort(Sort sort) {
        this.sort = sort;
        return this;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof BaseVo)) {
            return false;
        } else {
            BaseVo<?> other = (BaseVo)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label63: {
                    Object this$id = this.getId();
                    Object other$id = other.getId();
                    if (this$id == null) {
                        if (other$id == null) {
                            break label63;
                        }
                    } else if (this$id.equals(other$id)) {
                        break label63;
                    }

                    return false;
                }

                Object this$page = this.getPage();
                Object other$page = other.getPage();
                if (this$page == null) {
                    if (other$page != null) {
                        return false;
                    }
                } else if (!this$page.equals(other$page)) {
                    return false;
                }

                Object this$size = this.getSize();
                Object other$size = other.getSize();
                if (this$size == null) {
                    if (other$size != null) {
                        return false;
                    }
                } else if (!this$size.equals(other$size)) {
                    return false;
                }

                if (this.getSkip() != other.getSkip()) {
                    return false;
                } else {
                    Object this$sort = this.getSort();
                    Object other$sort = other.getSort();
                    if (this$sort == null) {
                        if (other$sort != null) {
                            return false;
                        }
                    } else if (!this$sort.equals(other$sort)) {
                        return false;
                    }

                    return true;
                }
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof BaseVo;
    }

    public int hashCode() {
//        int PRIME = true;
        int result = 1;
        Object $id = this.getId();
         result = result * 59 + ($id == null ? 43 : $id.hashCode());
        Object $page = this.getPage();
        result = result * 59 + ($page == null ? 43 : $page.hashCode());
        Object $size = this.getSize();
        result = result * 59 + ($size == null ? 43 : $size.hashCode());
        result = result * 59 + this.getSkip();
        Object $sort = this.getSort();
        result = result * 59 + ($sort == null ? 43 : $sort.hashCode());
        return result;
    }

    public String toString() {
        return "BaseVo(id=" + this.getId() + ", page=" + this.getPage() + ", size=" + this.getSize() + ", skip=" + this.getSkip() + ", sort=" + this.getSort() + ")";
    }
}
